class Solution {
public:
    int bitnum(int n)
    {
        int sum = 0;
        while (n)
        {
            int  t = n % 10;
            sum += t * t;
            n /= 10;
        }
        return sum;
    }

    bool isHappy(int n)
    {
        int  left = n, right = bitnum(n);
        while (left != right)
        {
            left = bitnum(left);
            right = bitnum(bitnum(right));
        }
        return left == 1;
    }
};

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1;
        long long  ret = 0;
        while (left < right)
        {
            long long v = min(height[left], height[right]) * (right - left);
            ret = max(ret, v);
            if (height[left] < height[right]) left++;
            else right--;
        }
        return (int)ret;

    }
};
class Solution {
public:
    int triangleNumber(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int n = nums.size();
        int sum = 0;
        for (int i = n - 1; i >= 2; i--)
        {
            int left = 0, right = i - 1;
            while (left < right)
            {
                if (nums[left] + nums[right] > nums[i])
                {
                    sum += right - left;
                    right--;
                }
                else
                    left++;

            }
        }
        return sum;

    }
};